<?php

echo $this->loadTemplate('left','default');

$tbl = JRequest::getVar('tbl');
$cid = $tbl.'_'.JRequest::getVar('cid');

$cate = JRequest::getVar('cate');
$folder = JRequest::getVar('id') ? '&id='.JRequest::getVar('id') : '';
?>
 <!-- END LEFT -->
<form action="index.php?<?php echo $_SERVER['QUERY_STRING'] ?>" method="post" name="adminForm" id="adminForm">
 <!-- CONTENT -->
 <div id="jm-content">    
    <div id="">     
     <h3 class="h_title">メッセージ表示</h3>
        <table border=0  id="table-view-message">
            <tr>
            <td>フォルダ</td>
            <td colspan="3"><b>「<?php echo $this->folder ?>」</b></td>                
            <td><button href="index.php?top=page&option=com_frmessage&task=delete&cate=<?php echo $cate?>&cid[]=<?php echo $cid.$folder ?>" class="confirm">削除</button></td>
            <td><button href="index.php?top=page&option=com_frmessage&task=reply&cate=<?php echo $cate?>&cid[]=<?php echo $cid.$folder ?>">返信</button></td>
            <td><button href="index.php?top=page&option=com_frmessage&task=forward&cate=<?php echo $cate?>&cid[]=<?php echo $cid.$folder ?>">転送</button></td>
            <td>
                <?php echo JHTML::_('Select.genericlist',$this->folders,"folders",'','FOME_CODE','FOME_NAME');?>
            </td>
            <td><!--<a href="#"><button>戻る</button></a>--></td>
            </tr>
            <tr>
                <td>送信者</td>
                <td colspan="2"><input type="text" readonly="true" value="<?php echo $this->mess->MESE_USEM_CODE?>"/></td>
                <td>日付</td>
                <td colspan="6"><input type="text" readonly="true" value="<?php echo $this->mess->MESE_DATE?>"/></td>
            </tr>
            <tr>
                <td>宛先</td>
                <td colspan="5"><input value="<?php echo $this->mess->MESE_OCBA_CODE?>" type="text" readonly="true" class="view-big"/></td>
                <td colspan="4">
                <?php echo JHTML::_('Select.genericlist',$this->unRead,"unRead",'','MERE_OCBA_CODE','MERE_OCBA_CODE');?>
                </td>
                
            </tr>
            <tr>
                <td>件名</td>
                <td colspan="7"><input value="<?php echo $this->mess->MESE_TITLE?>" type="text" readonly="true" class="view-bigx"></td>
                <td colspan="2"></td>
                
            </tr>
            <tr>
                <td>メッセージ</td>
                <td colspan="10">
                    <textarea readonly="true" rows="15" cols="72" ><?php echo $this->mess->MESE_BODY?></textarea>
                </td>
            </tr>
       </table>
           
                    <table id="tb_blue" style="width: 100%;">
            	       <thead>
                            <th></th>
                            <th>添付ファイル名</th>
                            <th>送信先</th>
                            <th>サイズ</th>
                        </thead>
                		<tbody>
                        
                        <?php 
                        if($this->mess->MESE_ATTA_CODE_LIST != 'null' && $this->mess->MESE_ATTA_CODE_LIST){
                          
                            $att = json_decode($this->mess->MESE_ATTA_CODE_LIST, true);
                          
                            $att = is_array($att) ? $att : (array)$att;
                                                        
                            $i = 1;
                            $img = "<img src='components/com_frmessage/public/images/checked-old.png'/>";
                            foreach($att as $k=>$rec){
                                $encode_k = sha1($k);
                                if(!file_exists(PATH_UPLOAD."/".$encode_k)){
                                    continue;
                                }
                                $size = filesize(PATH_UPLOAD."/".$encode_k);
                                $size = ceil($size/1024);
                                $link = "<a href='".PATH_DOWNLOAD.urlencode($k)."' target='_blank'>$k</a>";
                                echo "<tr>
                                    <td>$i</td>
                                    <td>$link</td>
                                    <td id='re_$k' class='$k' width='200'>$rec</td>
                                    <td>$size kb</td>
                                </tr>";
                                $i++;
                            }
                        }?>
                        </tbody>
                 </table>
   </div>
 </div>
 <!-- END CONTENT -->
    <input type="hidden" name="task" id="task" value=""/>                 
</form>